home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: news.ner.bbnplanet.net!arco!usenet
- From: Brian Leach <lasbfl>
- Subject: Re: How to prototype a class?
- X-Nntp-Posting-Host: 136.226.116.1
- Content-Type: text/plain; charset=us-ascii
- Message-ID: <Dn9449.1FB@news.arco.com>
- Sender: usenet@news.arco.com
- Content-Transfer-Encoding: 7bit
- Organization: ARCO Oil % Gas Company
- References: <4fvjhe$c6o@nuntius.u-net.net> <DMtxzu.8HK@tr.unisys.com> <4g9rrr$78s@news.NetVision.net.il>
- Mime-Version: 1.0
- Date: Fri, 23 Feb 1996 23:04:57 GMT
- X-Mailer: Mozilla 1.12 (X11; I; HP-UX A.09.05 9000/755)
- X-Url: news:4g9rrr$78s@news.NetVision.net.il
-
- Ivan Krivyakov <ivan@cmt.co.il> wrote:
- >"Benjamin M. Romer" <bmr1@trpo4.tr.unisys.com> wrote:
- >
- >> Use a forward declaration:
- >>
- >> class A; //I promise to define A later.
- >>
- >> class B
- >> {
- >> ...
- >> private:
- >> A dataMember; // <--- here is an error!
- >> };
- >>
- >> Class A
- >> {
- >> ...
- >> private:
- >> B dataMember;
- >> };
- >>
- >> Hope this helps.
- >>
- >> Benjamin M. Romer
- >
- >Sorry, but this won't work!
- >
- >In the point where you declare B::dataMember, class A is not still defined
- >although compiler knowns that it exists.
- >
- >To process a declaration of B::dataMember compiler should know, for example,
- >what is the size of objects of type A. This is obviously not known for one-pass compiler
- >in the point where B::dataMember is declared.
- >
- >You may use pointer to A instead of A as follows:
- >
- >class A;
- >
- >class B
- >{
- > ...
- > A* dataMember; //<--- legal
- > ...
- >};
- >
- >> #include <stddisclaim.h>
- >
- >Good idea! :)
- >
- >Best regards,
- >Ivan (ivan@cmt.co.il)
- >
- >
- If you don't use pointers, isn't this an infinitely recursive class?
- Hope you have a lot of memory...
-
-
- --
- Brian F. Leach
- Sr. Systems Analyst
- lasbfl@aai.arco.com
-
- Telephone: (907) 263-4860
- FAX: (907) 265-6298
-
- ARCO Alaska, Inc.
- ATO-1656
- P.O. Box 100360
- Anchorage, AK 99510-0360
-
-